package com.lanou3g.springmvc.utils;

import org.springframework.web.context.support.ServletContextResource;

import javax.servlet.ServletContext;

public class WebUtils {


    /**
     * 根据传入的相对于项目根路径的路径返回该路径在硬盘上的绝对路径
     * @param ctx
     * @param relativePath
     * @return
     */
    public static String getRealPath(ServletContext ctx, String relativePath) {
        ServletContextResource resource = new ServletContextResource(ctx, relativePath);
        return resource.getPath();
    }

}
